//
//  VSFindPaperCollectionViewCell.m
//  UI项目2.0
//
//  Created by dlios on 15/7/16.
//  Copyright (c) 2015年 星际科技. All rights reserved.
//

#import "VSFindPaperCollectionViewCell.h"
#import "VSFrameGrand.h"
#import "UIImageView+WebCache.h"
@implementation VSFindPaperCollectionViewCell

- (void)dealloc
{
    [_MainView release];
    [_LoveView release];
    [_LoveCountLabel release];
    [_paperModel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.MainView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.MainView];
        [_MainView release];
        
        self.LoveView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.LoveView];
        [_LoveView release];
        
        self.LoveCountLabel = [[UILabel alloc]init];
        self.LoveCountLabel.numberOfLines = 1;
        self.LoveCountLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.LoveCountLabel];
        [_LoveCountLabel release];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.MainView.frame = layoutAttributes.bounds;
    self.LoveView.frame = CGRectMake(10, layoutAttributes.frame.size.height - 26, 16, 16);
    self.LoveCountLabel.frame = CGRectMake(self.LoveView.frame.origin.x + self.LoveView.frame.size.width + 8, self.LoveView.frame.origin.y, 100, self.LoveView.frame.size.height);
}

- (void)setPaperModel:(VSFindPaperModel *)paperModel
{
    if (_paperModel != paperModel) {
        [_paperModel release];
        _paperModel = [paperModel retain];
    }
    
    
    NSString *url= [paperModel.image objectForKey:@"vip_original"];
    
    [self.MainView setImageWithURL:[NSURL URLWithString:url]];
    self.LoveView.image = [UIImage imageNamed:@"iconfont-xin.png"];
    [self.LoveCountLabel setTextColor:[UIColor whiteColor]];
    self.LoveCountLabel.text = [paperModel.counts objectForKey:@"loved"];
    
}







@end
